const {Article} = require('../../model/article');
const {Comment} = require('../../model/comment');
module.exports = async (req, res)=>{

    const id = req.query.id;

    let article = await Article.findOne({_id: id}).populate('author');
    let comments = await Comment.find({aid: id}).populate('uid');
    comments = JSON.parse(JSON.stringify(comments));
    let result = JSON.stringify(article);
    result = JSON.parse(result);
    res.render('home/article',{
        article: result,
        comment: comments
    });
};